#include "stdafx.h"
#include "ctime.h"

namespace Clock
{
	Time::Time()
	{
		myClock = MASTER_CLOCK;
		myTime = 0.0;
	}

	Time::Time(const Clocks aClock,const double aTime)
	{
		myClock = aClock;
		myTime = aTime;
	}

	Time::Time(const Time& aTime)
	{
		myClock = aTime.myClock;
		myTime = aTime.myTime;
	}

	Time::~Time()
	{
	}

	Time& Time::operator=(const Time& aTime)
	{
		myClock = aTime.myClock;
		myTime = aTime.myTime;
		return *this;
	}

	Time& Time::operator+=(const Time& aTime)
	{
		//myClock = aTime.myClock;
		myTime += aTime.myTime;
		return *this;
	}

	Time Time::operator+(const Time& aTime)
	{
		Time time(myClock, aTime.GetTime());
		time += *this;
		return time;
	}

	double Time::GetTime() const
	{
		return myTime;
	}

	Clocks Time::GetClock() const
	{
		return myClock;
	}

	bool Time::IsAfter(const Time &aTime) const
	{
		assert(myClock == aTime.myClock);
		return (myTime > aTime.myTime);
	}

	bool Time::IsBefore(const Time &aTime) const
	{
		assert(myClock == aTime.myClock);
		return (myTime < aTime.myTime);
	}

	void Time::Add(const Time &aTime)
	{
		//assert(myClock == aTime.myClock);
		myTime += aTime.myTime;
	}

	void Time::SetTime(const double &aTime)
	{
		myTime = aTime;
	}

	void Time::SetClock(const Clocks &aClock)
	{
		assert(aClock < NUMBER_OF_CLOCKS);
		myClock = aClock;
	}

	std::ostream &operator<<(std::ostream &o, const Time &aTime)
	{
		o << aTime.GetTime();
		return o;
	}
};
